package com.bblocks.standard.controller;



import com.bblocks.standard.feign.SysParamFeign2;
import com.bblocks.common.BaseController;
import com.bblocks.standard.entity.SysParam;
/*import com.bblocks.user.entity.vo.BaseUserInfoVo;
import com.bblocks.user.entity.vo.UserInfoViewVo;
import com.bblocks.user.feign.UserFeign;*/
import com.bblocks.util.R;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 系统配置(SysParam)表控制层
 *
 * @author makejava
 * @since 2021-10-29 13:57:44
 */
@Slf4j
@Tag(description = "sysParam2", name = "系统参数操作2")
@RestController
@RequestMapping("/system/sysParam2")
public class SysParamFeignController extends BaseController {
    @Autowired
    private SysParamFeign2 sysParamFeign2;

	@Operation(summary = "系统参数值提取", description = ""
			,parameters = {
				@Parameter(name = "paramName", description = "参数key",in = ParameterIn.PATH),
				@Parameter(name = "defaultValue", description = "默认值"),
			}
	)
    @GetMapping("/value/{paramName}")
    public R<String> selectOneValue(@PathVariable String paramName, String defaultValue) {
        Assert.notNull(paramName,"paramName参数不能为空！");
		R<String> paramValue = this.sysParamFeign2.selectOneValueInnner(paramName,defaultValue);
        return R.ok(paramValue.getData());
    }


	@Operation(summary = "系统参数提取", description = ""
			,parameters = {
			@Parameter(name = "paramName", description = "参数key",in = ParameterIn.PATH),
		}
	)
	@GetMapping("/obj/{paramName}")
	public R<SysParam> selectOne(@PathVariable String paramName) {
		Assert.notNull(paramName,"paramName参数不能为空！");
		R<SysParam> param = this.sysParamFeign2.selectOneInnner(paramName);
		return R.ok(param.getData());
	}



	@Operation(summary = "系统参数们提取", description = ""
			,parameters = {
			@Parameter(name = "paramName", description = "参数key",in = ParameterIn.PATH),
			@Parameter(name = "count", description = "数量"),
			}
	)
	@GetMapping("/objs/{paramName}/{count}")
	public R<List<SysParam>> selectOnes(@PathVariable String paramName,@PathVariable Integer count) {
		Assert.notNull(paramName,"paramName参数不能为空！");
		R<List<SysParam>> params = this.sysParamFeign2.selectOnesInnner(paramName,count);
		return R.ok(params.getData());
	}

}

